#ifndef CAMERA_H
#define CAMERA_H

#include <iostream>
#include <memory.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdalign.h>
#include <cstdint>

#include <linux/videodev2.h>

const int max_buffer = 32;
class CAMERA {
public:
    CAMERA(uint32_t width, uint32_t height);
    ~CAMERA();
    bool camera_init(uint32_t width, uint32_t height);
    void camera_on();
    uint8_t *camera_take_one(int *byte_used);
    void camera_off();
    void camera_close(void);
    void convertYUYVtoYUV420(uint8_t* yuyv, uint8_t* yuv420, int width, int height);
private:
    uint32_t width_,height_;
    struct v4l2_buffer imx_mapbuffer;
    int imx_buf_length[max_buffer];
    uint8_t *imx_mpaddr[max_buffer];

};


extern int camera_fd_;
#endif 
